package com.x.schedule.DAO.impl;

import com.x.schedule.DAO.BaseDao;
import com.x.schedule.DAO.SysUserDAO;
import com.x.schedule.pojo.SysSchedule;
import com.x.schedule.pojo.SysUser;
import org.junit.Before;
import org.junit.BeforeClass;

import java.util.List;
import java.util.Stack;

/**
 * ClassName: SysUserDAOImpl
 * Package: IntelliJ IDEA
 * Description:
 * Written by HanXu
 * Create 2024.08.25 15:23
 */

/**
 * 当前类：DAO接口实现类
 */
public class SysUserDAOImpl extends BaseDao implements SysUserDAO {
    @Override
    public SysUser findByUserName(String username) {
        String sql = "select uid, username, user_pwd as userPwd from sys_user where username = ?";
        List<SysUser> list = baseQuery(SysUser.class, sql, username);

        if(list != null && !list.isEmpty())
            return list.get(0);
        else
            return null;

    }

    @Override
    public int addSysUser(SysUser sysUser) {
        String sql = "insert into sys_user values(default, ?, ?)";
        int rows = baseUpdate(sql, sysUser.getUsername(), sysUser.getUserPwd());
        return rows;
    }


}
